package com.woniuxy.consumer.service.impl;

import com.woniuxy.commons.entity.PageBean;
import com.woniuxy.commons.entity.UserDetails;
import com.woniuxy.commons.utils.ResponseResult;
import com.woniuxy.commons.utils.ResultStatus;
import com.woniuxy.consumer.mapper.UserdetailsMapper;
import com.woniuxy.consumer.service.UserdetailsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author author
 * @create 2021-11-15 15:19
 */
@Service
public class UserdetailsServiceImpl implements UserdetailsService {

    @Resource
    private UserdetailsMapper userdetailsMapper;

    @Override
    public ResponseResult<PageBean<UserDetails>> selectUserDetailsByPageService(UserDetails userDetails, int pageIndex, int pageSize) {
        PageBean<UserDetails> pageBean = new PageBean<>();
        List<UserDetails> userDetails1 = userdetailsMapper.selectUserDetailsByPage(userDetails,
                pageIndex, pageSize);
        int i = userdetailsMapper.selectCountUserDetailsByPage(userDetails);
        pageBean.setBeanList(userDetails1);
        pageBean.setPageIndex(pageIndex);
        pageBean.setPageSize(pageSize);
        pageBean.setTotalRecord(i);
        return new ResponseResult<>(200, ResultStatus.SELECT_YES, "YES", pageBean);
    }
}
